<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
	<meta charset="UTF-8">
    <title>添加用户</title>
    <%@ include file="head.jsp" %>
</head>
<body>
<div class="layui-col-md12" style="height: 450px;">

        <div  style="width: 70%; height: 400px; margin: 0 auto;
            position: relative; top: 50%; transform: translateY(-50%);">

            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" name="user_name" required  lay-verify="required" placeholder="请输用户名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="user_password" required  placeholder="用户密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">用户级别</label>
                    <div class="layui-input-block">
                        <input type="text" name="user_power" required  lay-verify="number" placeholder="请输入0或1" autocomplete="off" class="layui-input">
                    </div>
                </div>
				<div class="layui-form-item">
				    <label class="layui-form-label">性别</label>
				    <div class="layui-input-block">
				      <input type="radio" name="sex" value="男" title="男">
				      <input type="radio" name="sex" value="女" title="女" checked>
				    </div>
				</div>
			    <div class="layui-form-item">
		   			<label class="layui-form-label">生日</label>
                    <div class="layui-input-block">
				      	<input id="bir" class="layui-input" name="bir" placeholder="请选择日期" />
                    </div>
			  	</div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-sm" lay-submit lay-filter="formDemo">确定</button>
                        <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">重置</button>
                    </div>
                </div>
                
            </form>
        </div>
    </div>



<script>
    //Demo
    layui.use(['form','laydate'], function(){
    	 var form = layui.form;
         var $ = layui.$;
         var element = layui.element;
         var layer = layui.layer;

         var laydate = layui.laydate;
         
         
         
         /* 显示当前时间函数  */
         function show(){
         	   var mydate = new Date();
         	   
         	   var str = "" + mydate.getFullYear() + "-";
         	   str += (mydate.getMonth()+1) + "-";
         	   str += mydate.getDate() ;
         	   return str;
         }
         
         /* 日期选择的初始化 */
        laydate.render({
 		    elem: '#bir'
 		    ,type:'date'
 		    ,max: show()
 		    ,btns: ['clear','now', 'confirm']
 		});
         
        form.on('submit(formDemo)', function(data,index){
            var data1 = JSON.stringify(data.field);
			
            $.post("add_user","data="+data1,function(msg){

				if(msg == "success"){
					layer.msg("添加用户成功！");
					location.href="user_select" ;
					//parent.location.reload();
				}
            });
			
            layer.close(index);
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index);

            
            return false;
        });
    });
</script>



</body>
</html>